package designPattern;

interface SaleHouse{
    void saleHouse();
}
class SaleHouseUtil implements SaleHouse{
    public void saleHouse() {
        System.out.println("终于买房了");
    }
}
class SaleHouseProxy implements SaleHouse{

    private SaleHouse SaleHouseUtil;

    public SaleHouseProxy(SaleHouseUtil saleHouse){
        this.SaleHouseUtil = saleHouse;
    }

    public void saleHouse() {
        System.out.println("开始中介介入(开启事务)");
        this.SaleHouseUtil.saleHouse();
        System.out.println("结束中介介入(提交事务)");
    }
}



/**
 * 静态代理**/
public class StaticProxy {

    public static void main(String[] args) {
        SaleHouseProxy saleHouseProxy = new SaleHouseProxy(new SaleHouseUtil());
        saleHouseProxy.saleHouse();
    }
}
